<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>电子签章合同列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox" >
                <div class="label">合同名称</div>
                <div class="field">
                    <input name="contractNm" id="contractNm" type="text" class="ui-textbox"  value="">
                </div>
            </div>
            <div class="fieldBox" >
                <div class="label">合同编号</div>
                <div class="field">
                    <input name="contractCode" id="contractCode" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox" >
                <div class="label">合同签署状态</div>
                <div class="field">
                    <select name="signSts" id="signSts">
                    	<option value=" " selected>请选择</option>
                    	<option value="1">已签署</option>
                    	<option value="0">未签署</option>
                    </select>
                </div>
            </div>
           <div class="fieldBox" >
                <div class="label">签署者名称</div>
                <div class="field">
                    <input name="signName" id="signName" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox" >
                <div class="label">签署者电话</div>
                <div class="field">
                    <input name="signNm" id="signNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox" >
                <div class="label">事业部</div>
                <div class="field">
                    <input name="orgNm" id="orgNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	               <span id="searchBtn" class="sq-button-round">查询</span>
	               <span id="clearBtn" class="sq-button-round">清空</span>
	               
	               
	               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	        </div>
        </div>
    </form>
</div>
<!-- 开票申请列表 -->
<div id="filEsignListGrid" class="sq-grid"></div> 
</div>

<script type="text/javascript">
    var grid = null, menu = null;
    $(function () {
        grid = $("#filEsignListGrid").ligerGrid({
            url: '<%=path%>/esign/filSign/initList.do',
            method: 'get',
            columns: [
                {display: '合同名称', name: 'contractNm', width: 140, align: 'center', enabledSort: false},
                {display: '业务系统合同编号', name: 'contractCode', width: 210, align: 'center', enabledSort: false},
                {display: '电子签章合同编号', name: 'contractNo', width: 210, align: 'center', enabledSort: false
                },
                {display: '合同状态', name: 'signSts', width: 180, align: 'center', enabledSort: false,
                	render:function (rowdata, rowindex, value, column) {
                		if(value != null && value == 1){
                			return '已签署';
                		}
						if((value != null && value == 0)){
                			return '未签署';
                		}
                	}		
                },
                {display: '创建时间', name: 'crtTm', width: 180, align: 'center',render:renderDate},
                {display:'事业部',name:'orgNm', width: 110, align: 'center', enabledSort: false},
                {display: '操作', name: 'filePath', width: 180, align: 'center', enabledSort: false,
                	render:function (rowdata, rowindex, value, column) {
                    debugger;
                        var rtnStr='';
                		if(value != null && value != ''){
                            rtnStr= '<a target="_downPdf'+rowdata.id+'" href="'+ value+'" >查看PDF</a>';
                		}else{
                            rtnStr= '<a onclick="toGetPath('+"'"+rowdata.contractNo+"'"+')" >下载</a>';
                		}
                        if(rowdata.contractFlowPath != null && rowdata.contractFlowPath != '') {
                            rtnStr=rtnStr+ '<a target="_downConFlowPdf'+rowdata.id+'" href="'+ rowdata.contractFlowPath+'" >查看流转合同</a>';
                        }
                        return rtnStr;
                	}
                }
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers:true,
            frozen: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onBeforeShowData: function ()
            {
                var grid = this;
                grid.collapsedRows = [];
            },
            isShowDetailToggle:function (row)
            {
            	if(row.audStsCd == CommonConstant.C_AUD_NO_HAPPEN_CODE || 
            			row.audStsCd == CommonConstant.C_AUD_ADNWAY_CODE){
            		return false;
            	}
            	return true;
            },
            detail: {
                height: 'auto',
                onShowDetail: showDetail_grid
            }
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
        	reLoadGrid();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
	        form.setData({  //重置select等特殊表单
				"signSts":" "
	        });
        });
        
        initForm();
    });
    
    
    //重新加载Grid
    function reLoadGrid(){
    	var form = liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            grid.setParm(name, data[name]);
        }
        grid.reload();
    }

    
    //初始化Form
    function initForm(){
		ligerPersonForm = $("#div_invoice_apply_valid_form").ligerForm({
         	 validate: true
  		});
    }

    //逾期明细列表
    function showDetail_grid(row, detailPanel, callback){
        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        detailGrid = $(gridBox).ligerGrid({
            //url: '<%=path%>/invoice/prjbillbscinfo/initList.do?applyId='+row.id,
            url: '<%=path%>/esign/filSignInfo/initList.do?filSignId='+row.id,
            method: 'get',
            columns: [
                {display: '角色',name: 'signRole',width: 180,align:'center'},
                {display: '姓名',name: 'signName',width: 150,align:'center'},
                {display: '电话', name: 'signNm', width: 180, align: 'center'},
                {display: '签署状态', name: 'signStsName', width: 180, align: 'center'},
                {display: '签署时间', name: 'sucTm', width: 180, align: 'center',render:renderDate}
            ],
            root: 'rows',
            hideLoadButton : true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers:true,  //显示序号
            allowUnSelectRow:true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false
        });
    }        		
	
    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
    function toGetPath(contractNo){
    	$.ajax({
            type: 'post',
            dataType: 'json',
            url: '<%=path%>/esign/filSign/getPath.do?contractNo='+contractNo,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({
                    content: LogUtils.LOG_CMM_DATA_LOADING,
                    SQ_type: "waitting"
                });
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                	grid.reload($('.pcontrol input', grid.toolbar).val());//加载到当前页
                	$.ligerDialog.SQalert({content: "下载成功", SQ_type: "success"});
                    //window.open(msg.info);
                	//window.open (msg.info,'newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
                } else {
                	$.ligerDialog.SQalert({content: "网络繁忙，请稍后再试", SQ_type: "error"});
                }
            }
        });
    }
</script>

</body>
</html>